package com.kude.manager;

import java.util.List;

import com.kude.dao.ProductCategoryDAO;
import com.kude.entity.ProductCategory;
import com.kude.util.BeanFactory;


public class ProductCategoryManager extends AbstractManager<ProductCategory,ProductCategoryDAO>{

	ProductCategoryDAO productCategoryDAO;
	
	public ProductCategoryManager() {
		this.tableName = ProductCategory.TABLE_NAME;
	}
	public List findByCategoryName(Object categoryName) {
		return productCategoryDAO.findByCategoryName(categoryName);
	}
	public List findAll() {
		return productCategoryDAO.findAll();
	}
	
	public boolean isExist(ProductCategory obj) throws OperException {
		if(obj == null) {
			throw new OperException("产品类别对象obj不能为空");
		}
		if(obj.getCategoryId() == null) {
			return false;
		}
		if(dao.getById(obj.getCategoryId()) == null) {
			return false;
		}
		return true;
	}
	
	public void setProductCategoryDAO(ProductCategoryDAO productCategoryDAO) {
		this.dao = productCategoryDAO;
	}

}
